<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>获取同辈元素</title>
</head>
<body>
<input type="text">
<input type="text" id="testId">
<!--<input type="text">-->
</body>
<script type="text/javascript">
    var testId = document.getElementById("testId");
    //获取上一个同辈元素
    console.log(testId.previousElementSibling)
    //获取洗一个同辈元素
    console.log(testId.nextElementSibling)
    console.log(document.getElementsByTagName("body")[0].nextElementSibling)
</script>
</html>